using System.Management.Automation;
using System.IO;

namespace PSSymbolStore.Commands
{
    [Cmdlet(VerbsCommon.Unlock, "Transaction", SupportsShouldProcess = true)]
    public class UnlockTransactionCommand : TransactionCommandBase
    {
        protected override bool CreateSymbolStore
        {
            get
            {
                return false;
            }
        }

        protected override void ProcessTransaction(string transactionId)
        {
            string lockFile = SymbolStoreObject.GetTransactionLockedFile(transactionId);
            if (File.Exists(lockFile))
            {
                if (ShouldProcess(transactionId, "Unlock Transaction"))
                {
                    File.Delete(lockFile);
                }
            }

            base.ProcessTransaction(transactionId);
        }
    }
}
